package com.atguigu.gmall.cart.service.impl;

import com.atguigu.gmall.cart.mapper.CartInfoMapper;
import com.atguigu.gmall.cart.service.CartAsyncService;
import com.atguigu.gmall.model.cart.CartInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Transactional(rollbackFor = Exception.class)
@Service
public class CartAsyncServiceImpl implements CartAsyncService {
    @Autowired
    private CartInfoMapper cartInfoMapper;
    /**
     * 修改方法
     *
     * @param cartInfo
     */
    @Async("cart")
    @Override
    public void update(CartInfo cartInfo) {
         //更新数据库
        cartInfoMapper.updateById(cartInfo);
    }

    /**
     * 新增方法
     *
     * @param cartInfo
     */
    @Async("cart")
    @Override
    public void add(CartInfo cartInfo) {
        //新增数据库
        cartInfoMapper.insert(cartInfo);
    }
}
